<template>
	<view>
		<!-- <image class="order-bg" mode="widthFix" :src="imageUrl +'list/bg.png'"> -->
		<u-sticky>
			<view class="m-head1">
				<image class="bg" mode="widthFix" :src="imageUrl +'list/bg1.png'"></image>
				<u-navbar :leftText="kind==0?'月卡续费':'错峰续费'" @rightClick="rightClick" :autoBack="true" placeholder
					:safeAreaInsetTop="true" :bgColor="bgColor">
				</u-navbar>
			</view>
		</u-sticky>

		<view class="row-order">
			<view class="wp">
				<view class="card-list">
					<view v-for="item in parkingRecords" :key="item.id" class="card-item">
						<view class="card-header">
							<text class="plate">{{ item.plate }}</text>
							<text class="money">¥{{ item.payMoney }}</text>
						</view>
						<view class="card-body">
							<view class="row">
								<text class="label">车场(组)：</text>
								<text>{{ item.parkName }}</text>
							</view>
							<view class="row">
								<text class="label">套餐名称：</text>
								<text>{{ item.packageName || '无' }}</text>
							</view>
							<view class="row">
								<text class="label">续费周期：</text>
								<text>{{ formatDateRange(item.period) }}</text>
							</view>
							<view class="row">
								<text class="label">支付时间：</text>
								<text>{{ item.payTime }}</text>
							</view>
							<view class="row">
								<text class="label">支付方式：</text>
								<text><!-- {{ payModeMap[item.payMode] || '钱包' }} -->{{item.payMode}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		commonSelect
	} from '../../api/myHttps.js';

	export default {
		data() {
			return {
				// 头部背景色
				bgColor: 'transparent',
				kind: 0,
				parkingRecords: [],
				payModeMap: {
					wallet: '钱包',
					alipay: '支付宝', 
					wechat: '微信' 
				}
			}
		},
		onLoad(options) {
			this.kind = options.kind;
			this.getList();
		},
		methods: {
			getList(){
				let data = {
					"key": "my_renew_rec_zkh",
					"phone": uni.getStorageSync('phone'),
					"parameter": {
						"kind": this.kind,
						"ownerId": uni.getStorageSync('ownerId')
					}
				};
				commonSelect(data).then((res) => {
					this.parkingRecords = res.records;
				})
			},
			formatDateRange(period) {
				if (!period) return '';
				const parts = period.split('~~');
				if (parts.length === 2) {
					return `${parts[0]} 至 ${parts[1]}`;
				}
				return period;
			},
		}
	}
</script>

<style>
	page {
		background-color: #F4FAF7;
	}

	.card-list {
		display: flex;
		flex-direction: column;
		gap: 20rpx;
	}

	.card-item {
		background-color: #ffffff;
		border-radius: 16rpx;
		padding: 30rpx;
		box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
	}

	.card-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.plate {
		font-size: 36rpx;
		font-weight: bold;
		color: #333;
	}

	.money {
		font-size: 32rpx;
		color: #e74c3c;
		font-weight: bold;
	}

	.card-body .row {
		display: flex;
		margin-bottom: 12rpx;
		font-size: 28rpx;
		color: #666;
	}

	.label {
		width: 140rpx;
		color: #999;
	}
</style>